package perso.perso.view.admin.user;

import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.Set;

import perso.perso.converteur.BeanBooleanConverteur;
import perso.perso.converteur.BeanUserDateConverteur;
import perso.perso.view.admin.school.BeanClass;
import perso.perso.view.admin.school.BeanSchool;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.annotations.XStreamImplicit;


@XStreamAlias("user")
public class BeanUser {
	@XStreamAsAttribute
	private String name;
	@XStreamAsAttribute 
	private String surname;
	@XStreamConverter(BeanUserDateConverteur.class)
	private Date birthday;
	@XStreamAsAttribute 
	private Integer id;
	@XStreamConverter(BeanUserDateConverteur.class)
	private Date createDate;
	@XStreamAsAttribute 
	private Integer idClass;
	@XStreamConverter(BeanBooleanConverteur.class) 
	private Boolean isProfessor;
	@XStreamImplicit
	private Set<BeanClass> classes = new HashSet<BeanClass>(0);
	@XStreamAsAttribute 
	private BeanClass userClass;
	
	private Integer day;
	private Integer month;
	private Integer year;
	private Integer schoolSelected;
	
	
	

	public Integer getSchoolSelected() {
		return schoolSelected;
	}

	public void setSchoolSelected(Integer schoolSelected) {
		this.schoolSelected = schoolSelected;
	}

	public Integer getDay() {
		return day;
	}

	public void setDay(Integer day) {
		this.day = day;
	}

	public Integer getMonth() {
		return month;
	}

	public void setMonth(Integer month) {
		this.month = month;
	}

	public Integer getYear() {
		return year;
	}

	public void setYear(Integer year) {
		this.year = year;
	}

	public BeanUser(){
		System.out.println("constructeur");
	}
	
	public BeanUser(Integer id, String name, String surname, Date birthday){
		this.name = name;
		this.surname = surname;
		this.birthday = birthday;
		this.id = id;
	}
	
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSurname() {
		return surname;
	}
	public void setSurname(String surname) {
		this.surname = surname;
	}

	@SuppressWarnings("deprecation")
	public Date getBirthday() {
		if(birthday == null && this.day != null && this.month != null && this.year != null){
			birthday = (new GregorianCalendar(year, month-1, day)).getTime();
		} 
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Integer getIdClass() {
		return idClass;
	}

	public void setIdClass(Integer idClass) {
		this.idClass = idClass;
	}

	

	public Boolean getIsProfessor() {
		return isProfessor!=null?isProfessor:false;
	}

	public void setIsProfessor(Boolean isProfessor) {
		this.isProfessor = isProfessor;
	}

	public Set<BeanClass> getClasses() {
		return classes;
	}

	public void setClasses(Set<BeanClass> classes) {
		this.classes = classes;
	}

	public BeanClass getUserClass() {
		return userClass;
	}

	public void setUserClass(BeanClass userClass) {
		this.userClass = userClass;
	}
	
	
	
	
	
}
